package cn.iocoder.yudao.module.famous.doctor.controller.app.famNoticeClose;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.famous.doctor.controller.app.famNoticeClose.vo.*;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.famNoticeClose.FamNoticeCloseDO;
import cn.iocoder.yudao.module.famous.doctor.convert.famNoticeClose.FamNoticeCloseConvert;
import cn.iocoder.yudao.module.famous.doctor.service.famNoticeClose.FamNoticeCloseService;

@Tag(name = "用户 APP - 中医-公告用户关闭")
@RestController
@RequestMapping("/famous.doctor/fam-notice-close")
@Validated
public class AppFamNoticeCloseController {

    @Resource
    private FamNoticeCloseService famNoticeCloseService;

    @PostMapping("/create")
    @Operation(summary = "创建中医-公告用户关闭")

    public CommonResult<Long> createFamNoticeClose(@Valid @RequestBody AppFamNoticeCloseCreateReqVO createReqVO) {
        return success(famNoticeCloseService.createFamNoticeClose(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新中医-公告用户关闭")

    public CommonResult<Boolean> updateFamNoticeClose(@Valid @RequestBody AppFamNoticeCloseUpdateReqVO updateReqVO) {
        famNoticeCloseService.updateFamNoticeClose(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除中医-公告用户关闭")
    @Parameter(name = "id", description = "编号", required = true)

    public CommonResult<Boolean> deleteFamNoticeClose(@RequestParam("id") Long id) {
        famNoticeCloseService.deleteFamNoticeClose(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得中医-公告用户关闭")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")

    public CommonResult<AppFamNoticeCloseRespVO> getFamNoticeClose(@RequestParam("id") Long id) {
        FamNoticeCloseDO famNoticeClose = famNoticeCloseService.getFamNoticeClose(id);
        return success(FamNoticeCloseConvert.INSTANCE.convert(famNoticeClose));
    }

    @GetMapping("/list")
    @Operation(summary = "获得中医-公告用户关闭列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")

    public CommonResult<List<AppFamNoticeCloseRespVO>> getFamNoticeCloseList(@RequestParam("ids") Collection<Long> ids) {
        List<FamNoticeCloseDO> list = famNoticeCloseService.getFamNoticeCloseList(ids);
        return success(FamNoticeCloseConvert.INSTANCE.convertList(list));
    }

    @GetMapping("/page")
    @Operation(summary = "获得中医-公告用户关闭分页")

    public CommonResult<PageResult<AppFamNoticeCloseRespVO>> getFamNoticeClosePage(@Valid AppFamNoticeClosePageReqVO pageVO) {
        PageResult<FamNoticeCloseDO> pageResult = famNoticeCloseService.getFamNoticeClosePage(pageVO);
        return success(FamNoticeCloseConvert.INSTANCE.convertPage(pageResult));
    }

    @GetMapping("/export-excel")
    @Operation(summary = "导出中医-公告用户关闭 Excel")

    @OperateLog(type = EXPORT)
    public void exportFamNoticeCloseExcel(@Valid AppFamNoticeCloseExportReqVO exportReqVO,
              HttpServletResponse response) throws IOException {
        List<FamNoticeCloseDO> list = famNoticeCloseService.getFamNoticeCloseList(exportReqVO);
        // 导出 Excel
        List<AppFamNoticeCloseExcelVO> datas = FamNoticeCloseConvert.INSTANCE.convertList02(list);
        ExcelUtils.write(response, "中医-公告用户关闭.xls", "数据", AppFamNoticeCloseExcelVO.class, datas);
    }

}
